<!DOCTYPE html>
<html class="no-js" lang="zh">
  <head>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="alternate" href="https://www.desgard.com" hreflang="pt-BR">
<link href="http://gmpg.org/xfn/11" rel="profile">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="theme-color" content="#005344">
<title>Guardia · 瓜地</title>
<meta name="google-site-verification" content="zS1dSn20XtA4FJYEOQLXqI0boxZdMnJ2g3beje-cl20">
<meta name="description" content="Drip Into A River Animation">
<meta name="keywords" content="">
<!-- Social: Facebook / Open Graph -->
<meta property="og:url" content="https://www.desgard.com/DGDownloaderButton-2/">
<meta property="og:title" content="       Drip Into A River · Part II | Gua  ">
<meta property="og:description" content="Drip Into A River Animation">
<meta property="og:site_name" content="Desgard_Duan">
<meta property="og:locale" content="pt_BR">
<meta property="og:type" content="website">
<meta property="og:author" content="https://www.facebook.com/desgard.duan">
<meta property="og:image" content="https://www.desgard.com">
<!-- Social: Twitter -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@nandomoreirame">
<meta name="twitter:domain" content="https://www.desgard.com">
<meta name="twitter:title" content="       Drip Into A River · Part II | Gua  ">
<meta name="twitter:description" content="Drip Into A River Animation">
<meta name="twitter:image:src" content="https://www.desgard.com">
<!-- Favicons -->
<link rel="apple-touch-icon" sizes="114x114" href="https://www.desgard.com/assets/ico/apple-touch-icon-114-516f4e19976b9e4dbb77ad9b576831fe.png">
<link rel="apple-touch-icon" sizes="72x72" href="https://www.desgard.com/assets/ico/apple-touch-icon-72-5409b2df229305703caf583d86c845ab.png">
<link rel="apple-touch-icon" href="https://www.desgard.com/assets/ico/apple-touch-icon-57-aa873e019cf659e0d4e6a0b5bb9f379d.png">
<link rel="shortcut icon" href="https://www.desgard.com/assets/ico/favicon-4298be3d3fbe23e18d65bded9d930899.png">
<!-- rel prev and next -->
<!-- Canonical link tag -->
<link rel="canonical" href="https://www.desgard.com/DGDownloaderButton-2/">
<link rel="alternate" type="application/rss+xml" title="Gua" href="https://www.desgard.com/feed.xml">
<link rel="stylesheet" href="/assets/main-0b7b828712f4c43b75bba4861c907bb1.css">
<script src="/assets/modernizr-custom-cb807611a3e262b2eac59444cbab74d6.js" data-cfasync="false"></script>
<script src="/assets/js/jquery-3.1.js"></script>
<script src="/assets/js/jquery.rotate.js"></script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Website",
  "publisher": "www.desgard.com",
  "url": "http://www.desgard.com/",
  "description": "瓜地"
}
</script>
<script type="text/javascript">
  var disqus_shortname = 'desgard',
      baseurl          = '';
</script>
<!--
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-52446115-1']);
_gaq.push(['_trackPageview']);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>-->
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?c5a8123bc51782a3083a631ed9ff50e4";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        inlineMath: [ ['$','$'] ],
        displayMath: [ ['$$','$$'] ],
        processEscapes: true
      }
    });
  </script>
  </head>
  <body class="post-template single">
    <header class="header">
  <div class="container">
    <h1><a href="/"><strong>desgard</strong>.com</a></h1>
    <nav class="navbar">
      <ul>
        <li><a href="/">Home</a></li>
        <li><a href="#!" data-modal="modalSearch"><i class="fa fa-search"></i></a></li>
        <li><a href="/comment " target="_blank"><i class="fa fa-comments"></i></a></li>
        <li><a href="/feed.xml" target="_blank"><i class="fa fa-feed"></i></a></li>
      </ul>
    </nav>
  </div>
</header>
    <main class="wrapper container" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/Blog">
      <article class="post" itemscope="itemscope" itemtype="http://schema.org/BlogPosting" itemprop="blogPost">
  <header class="post-header">
    <h1>Drip Into A River · Part II</h1>
    <div class="post-meta">
      <time datetime="2015-10-13">
        <i class="fa fa-calendar-o"></i> <time datetime="2016-06-29"> 2016-06-29
      </time>
      <span>
        <i class="fa fa-comments"></i> <a href="#container">Comment me!</a>
      </span>
      <span>
<!--
-->
      </span>
    </div>
  </header>
  <blockquote>
  <p>这篇是关于水滴汇集特效的系列二，如果没有看过系列一，可以点击<a href="https://desgard.com/2016/06/28/DGDownloaderButton/">这里</a>查看。</p>
</blockquote>
<h2 id="section">“振动波”效果</h2>
<p>分解一下震动效果的全过程。</p>
<p><img src="http://7xwh85.com1.z0.glb.clouddn.com/img_1.gif" width="300px" /></p>
<p>稍加注意，整个动画需要由4各部分组成：</p>
<ul>
  <li>效果一：整体视图先变小；</li>
  <li>效果二：瞬间变大，然后变小并带有弹簧效果；</li>
  <li>效果三：在效果二的同时，复制视图，将复制的视图逐渐变大，并修改其<em>alpha</em>值;</li>
  <li>效果四：在效果二、效果三的同时，提示用户处于已完成的状态</li>
</ul>
<p>在排除效果四的情况下，其余效果我们都可以通过<em>UIView Animation</em>来实现。我先给出代码。</p>
<div class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="c1">#pragma mark - 结束动画</span>
<span class="o">-</span> <span class="p">(</span><span class="n">void</span><span class="p">)</span> <span class="n">endAnimation</span> <span class="p">{</span>
    <span class="nb">self</span><span class="o">.</span><span class="n">layer</span><span class="o">.</span><span class="n">borderColor</span> <span class="o">=</span> <span class="o">[</span><span class="no">UIColor</span> <span class="n">clearColor</span><span class="o">].</span><span class="n">CGColor</span><span class="p">;</span>
    <span class="sr">//</span> <span class="err">定义复制视图，使用以下方法</span>
    <span class="sr">//</span> <span class="err">其实是新定义一个</span><span class="no">UIView</span><span class="err">，然后将其所有属性拷贝过来</span>
    <span class="no">UIView</span> <span class="o">*</span><span class="n">viewShot</span> <span class="o">=</span> <span class="o">[</span><span class="no">NSKeyedUnarchiver</span> <span class="ss">unarchiveObjectWithData</span><span class="p">:</span><span class="o">[</span><span class="no">NSKeyedArchiver</span> <span class="ss">archivedDataWithRootObject</span><span class="p">:</span> <span class="nb">self</span><span class="o">.</span><span class="n">progressView</span><span class="o">]]</span><span class="p">;</span>
    <span class="n">viewShot</span><span class="o">.</span><span class="n">alpha</span> <span class="o">=</span> <span class="mi">0</span><span class="o">.</span><span class="mi">4</span><span class="n">f</span><span class="p">;</span>
    <span class="n">viewShot</span><span class="o">.</span><span class="n">layer</span><span class="o">.</span><span class="n">cornerRadius</span> <span class="o">=</span> <span class="n">viewShot</span><span class="o">.</span><span class="n">frame</span><span class="o">.</span><span class="n">size</span><span class="o">.</span><span class="n">width</span> <span class="o">/</span> <span class="mi">2</span><span class="o">.</span><span class="n">f</span><span class="p">;</span>
    <span class="sr">//</span> <span class="err">为了不影响缩小后的视觉，所以提前将复制视图缩小</span>
    <span class="n">viewShot</span><span class="o">.</span><span class="n">transform</span> <span class="o">=</span> <span class="no">CGAffineTransformMakeScale</span><span class="p">(</span><span class="o">.</span><span class="mi">9</span><span class="p">,</span> <span class="o">.</span><span class="mi">9</span><span class="p">);</span>
    <span class="o">[</span><span class="nb">self</span> <span class="ss">addSubview</span><span class="p">:</span> <span class="n">viewShot</span><span class="o">]</span><span class="p">;</span>
    <span class="sr">//</span> <span class="err">视图缩小动画</span>
    <span class="o">[</span><span class="no">UIView</span> <span class="ss">animateWithDuration</span><span class="p">:</span> <span class="o">.</span><span class="mi">9</span>
                          <span class="ss">delay</span><span class="p">:</span> <span class="mi">1</span><span class="o">.</span><span class="mi">2</span>
                        <span class="ss">options</span><span class="p">:</span> <span class="no">UIViewAnimationOptionCurveEaseInOut</span>
                     <span class="ss">animations</span><span class="p">:</span><span class="o">^</span><span class="p">{</span>
                         <span class="n">_progressView</span><span class="o">.</span><span class="n">transform</span> <span class="o">=</span> <span class="no">CGAffineTransformMakeScale</span><span class="p">(</span><span class="o">.</span><span class="mi">9</span><span class="p">,</span> <span class="o">.</span><span class="mi">9</span><span class="p">);</span>
                     <span class="p">}</span>
                     <span class="ss">completion</span><span class="p">:</span><span class="o">^</span><span class="p">(</span><span class="no">BOOL</span> <span class="n">finished</span><span class="p">)</span> <span class="p">{</span>
                         <span class="sr">//</span> <span class="err">“振动波”效果</span>
                         <span class="o">[</span><span class="no">UIView</span> <span class="ss">animateWithDuration</span><span class="p">:</span> <span class="mi">2</span><span class="o">.</span><span class="mi">1</span>
                                          <span class="ss">animations</span><span class="p">:</span><span class="o">^</span><span class="p">{</span>
                                              <span class="n">viewShot</span><span class="o">.</span><span class="n">transform</span> <span class="o">=</span> <span class="no">CGAffineTransformMakeScale</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
                                              <span class="n">viewShot</span><span class="o">.</span><span class="n">alpha</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
                                              <span class="sr">//</span> <span class="err">显示完成状态标识</span>
                                              <span class="nb">self</span><span class="o">.</span><span class="n">successView</span><span class="o">.</span><span class="n">alpha</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
                                          <span class="p">}</span>
                                          <span class="ss">completion</span><span class="p">:</span><span class="o">^</span><span class="p">(</span><span class="no">BOOL</span> <span class="n">finished</span><span class="p">)</span> <span class="p">{</span>
                                              <span class="o">[</span><span class="n">viewShot</span> <span class="n">removeFromSuperview</span><span class="o">]</span><span class="p">;</span>
                                          <span class="p">}</span><span class="o">]</span><span class="p">;</span>
                         <span class="sr">//</span> <span class="err">弹簧震动效果</span>
                         <span class="o">[</span><span class="no">UIView</span> <span class="ss">animateWithDuration</span><span class="p">:</span> <span class="mi">1</span><span class="o">.</span><span class="n">f</span>
                                               <span class="ss">delay</span><span class="p">:</span> <span class="mi">0</span><span class="o">.</span><span class="mi">2</span> <span class="o">//</span> <span class="err">延时</span><span class="mi">2</span><span class="n">s</span><span class="err">，测试得出最好效果</span>
                              <span class="ss">usingSpringWithDamping</span><span class="p">:</span> <span class="mi">0</span><span class="o">.</span><span class="mi">4</span>
                               <span class="ss">initialSpringVelocity</span><span class="p">:</span> <span class="mi">0</span>
                                             <span class="ss">options</span><span class="p">:</span> <span class="no">UIViewAnimationOptionCurveEaseInOut</span>
                                          <span class="ss">animations</span><span class="p">:</span><span class="o">^</span><span class="p">{</span>
                                              <span class="sr">//</span> <span class="err">视图瞬间增大一下</span>
                                              <span class="n">_progressView</span><span class="o">.</span><span class="n">transform</span> <span class="o">=</span> <span class="no">CGAffineTransformMakeScale</span><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="mi">8</span><span class="p">,</span> <span class="mi">1</span><span class="o">.</span><span class="mi">8</span><span class="p">);</span>
                                              <span class="n">_progressView</span><span class="o">.</span><span class="n">transform</span> <span class="o">=</span> <span class="no">CGAffineTransformMakeScale</span><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="o">.</span><span class="mi">0</span><span class="p">);</span>
                                          <span class="p">}</span>
                                          <span class="ss">completion</span><span class="p">:</span><span class="o">^</span><span class="p">(</span><span class="no">BOOL</span> <span class="n">finished</span><span class="p">)</span> <span class="p">{</span>
                                          <span class="p">}</span><span class="o">]</span><span class="p">;</span>
                     <span class="p">}</span><span class="o">]</span><span class="p">;</span>
<span class="p">}</span></code></pre></div>
<p>由于多个参数，多个block，代码可能有点乱，将窗口拉大至能够单行显示每一行代码，就可以很清晰的看出嵌套层次。</p>
<p>在弹簧的震动效果中的<code>delay</code>和<code>usingSpringWithDamping</code>即延时和震动阻尼两个参数上，我做了多次试验，也询问了身边同学的意见，最终决定了此参数。另外一个需要注意的地方，虽然完成后的<strong>√</strong>并不是我们动画的主要部分，这个特效我自己也尝试了一下，感觉效果不佳，所以我最终采用渐变的方法使它出现。对于原型图上的动效方式，可以参考一下<a href="https://github.com/rakaramos/OnOffButton">OnOffButton</a>。</p>
<p>以下是实际效果：</p>
<p><img src="http://7xwh85.com1.z0.glb.clouddn.com/img_2.gif" width="300px" /></p>
<h2 id="section-1">关于水滴粘连动画的讨论</h2>
<p>在水滴汇集的动画中，需要在中心位置展示进度的视图逐渐增大。虽然这样效果可以实现，但是有一些细节问题。例如系列一提到的<strong>水滴粘连效果</strong>。例如下图：</p>
<p><img src="http://7xwh85.com1.z0.glb.clouddn.com/img_3-1.jpg" width="300px" /></p>
<p>我在之前写过一篇<a href="https://desgard.com/2016/05/28/DGSlimeView/">文章</a>，是<a href="http://kittenyang.com/drawablebubble/">Kitten-Yang</a>给出的一个<em>Bubble效果</em>的思路，通过贝塞尔曲线实现这种效果。另外，更进一步的，也可以使用<em>计算机图形学</em>中的<strong><a href="https://en.wikipedia.org/wiki/Metaballs">元球算法(Metaball)</a></strong>来实现这个效果。</p>
<p>虽然我这里有很多思路，但是我在给出的实例代码中并没有采纳。因为在第一版代码中，我做了尝试，使用的是<em>Kitten-Yang</em>的<em>Bubble效果</em>。在重绘界面的时候使用了<code>CADisplayLink</code>。于此，进度动画也就不能使用单纯的<strong>UIKit Animation</strong>进行制作。所以对于进度圆的制作，我用了<code>CAShapelayer</code>不断的来画圆，每次半径增加一点，然后<code>CADisplayLink</code>刷新视图，继续画圆……如此循环。虽然实现上没有什么问题，而且每种状态的进度圆半径我都能获取到，但是随着运行动画时间的增加，硬件加速经常会有卡顿的情况，以至于最终水滴动画都无法很流畅的展示。再三考虑，我更换了思路。</p>
<p>这个也是一直困扰着我的原因，我没有更好的思路来实现粘连动画，所以最终放弃了它。倘若各位围观大神有更好的思路，欢迎大家的建议，小弟也不胜感激。</p>
<h2 id="section-2">对于第一篇文章的一些疑问</h2>
<h4 id="q-">Q: 笔者在文中的插图是如何制作的？</h4>
<p>说实话，我没有更好的方式。我是用Keynote将自定义图形组合而来。这是受到了<em>Kitten-Yang</em>的启发，我是他的粉丝。</p>
<h4 id="q--1">Q: 笔者在第一篇中，是如何做到在外围圆环上随机生成水滴？</h4>
<p>其实只是将周角分为360份，然后对这360个度数做了随机，得到角度后如下计算坐标。当然当角度大于180°时候更改下三角函数符号即可。</p>
<p><img src="http://7xwh85.com1.z0.glb.clouddn.com/img_4.jpeg" /></p>
<div class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="c1">#pragma mark - 计算Begin Point Postion</span>
<span class="o">+</span> <span class="p">(</span><span class="no">CGPoint</span><span class="p">)</span> <span class="ss">calcBeginPoint</span><span class="p">:</span> <span class="p">(</span><span class="no">CGPoint</span><span class="p">)</span><span class="n">O</span> <span class="ss">radius</span><span class="p">:</span> <span class="p">(</span><span class="no">CGFloat</span><span class="p">)</span><span class="n">r</span> <span class="ss">coefficent</span><span class="p">:</span> <span class="p">(</span><span class="no">CGFloat</span><span class="p">)</span><span class="n">c</span> <span class="p">{</span>
    <span class="no">CGFloat</span> <span class="n">dis</span> <span class="o">=</span> <span class="n">r</span> <span class="o">*</span> <span class="n">c</span><span class="p">;</span>
    <span class="no">CGPoint</span> <span class="n">ans</span><span class="p">;</span>
    <span class="sr">//</span> <span class="err">生成角度</span>
    <span class="n">int</span> <span class="n">angel</span> <span class="o">=</span> <span class="n">arc4random</span><span class="p">()</span> <span class="o">%</span> <span class="mi">360</span><span class="p">;</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">angel</span> <span class="o">&lt;=</span> <span class="mi">180</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">double</span> <span class="n">theta</span> <span class="o">=</span> <span class="p">(</span><span class="n">double</span><span class="p">)</span><span class="n">angel</span> <span class="o">/</span> <span class="mi">360</span> <span class="o">*</span> <span class="no">M_PI</span> <span class="o">*</span> <span class="mi">2</span><span class="p">;</span>
        <span class="n">ans</span> <span class="o">=</span> <span class="no">CGPointMake</span><span class="p">(</span><span class="n">O</span><span class="o">.</span><span class="n">x</span> <span class="o">+</span> <span class="n">dis</span> <span class="o">*</span> <span class="n">cos</span><span class="p">(</span><span class="n">theta</span><span class="p">),</span> <span class="n">O</span><span class="o">.</span><span class="n">y</span> <span class="o">-</span> <span class="n">dis</span> <span class="o">*</span> <span class="n">sin</span><span class="p">(</span><span class="n">theta</span><span class="p">));</span>
    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
        <span class="n">double</span> <span class="n">theta</span> <span class="o">=</span> <span class="p">(</span><span class="n">double</span><span class="p">)(</span><span class="mi">360</span> <span class="o">-</span> <span class="n">angel</span><span class="p">)</span> <span class="o">/</span> <span class="mi">360</span> <span class="o">*</span> <span class="no">M_PI</span> <span class="o">*</span> <span class="mi">2</span><span class="p">;</span>
        <span class="n">ans</span> <span class="o">=</span> <span class="no">CGPointMake</span><span class="p">(</span><span class="n">O</span><span class="o">.</span><span class="n">x</span> <span class="o">+</span> <span class="n">dis</span> <span class="o">*</span> <span class="n">cos</span><span class="p">(</span><span class="n">theta</span><span class="p">),</span> <span class="n">O</span><span class="o">.</span><span class="n">y</span> <span class="o">+</span> <span class="n">dis</span> <span class="o">*</span> <span class="n">sin</span><span class="p">(</span><span class="n">theta</span><span class="p">));</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="n">ans</span><span class="p">;</span>
<span class="p">}</span></code></pre></div>
<h2 id="section-3">尾声</h2>
<p>对于水滴汇集按钮特效的思路解析大概就是这样。自己在制作该作品的过程中巩固了一下<strong>UIKit Animation</strong>、<strong>Core Animation</strong>，又一次实践了<strong>贝塞尔曲线</strong>，收获很大。在阅读完<a href="https://www.gitbook.com/book/zsisme/ios-/details"><em>iOS Core Animation: Advanced Techniques</em></a>之后，在实习之余自己会更加关注<em>facebook</em>的<strong>pop</strong>动画库以及<strong>Swift 3.0</strong>中的<code>UIViewPropertyAnimator</code>类。希望以后能继续为大家分享知识。</p>
<p>这次微博转发量有点大，自己也受宠若惊~还是多谢大家支持。</p>
<hr />
<p><a href="https://github.com/dgytdhy/DGDownloaderButton">DGDownloaderButton Source Code</a></p>
  <footer class="post-footer">
    <section class="author">
      <h4>Desgard_Duan</h4>
      <p>I write many code to write less code.💻</p>
    </section>
<aside class="share">
  <h4>Share this.</h4>
  <a href="http://twitter.com/share?text=《Drip Into A River · Part II》 -- Guardia · 瓜地&amp;url=https://www.desgard.com/DGDownloaderButton-2/"
  onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
    <i class="fa fa-twitter-square"></i>
  </a>
  <a href="http://v.t.sina.com.cn/share/share.php?url=https://www.desgard.com/DGDownloaderButton-2/&amp;title=《Drip Into A River · Part II》 —— Guardia · 瓜地" onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
    <i class="fa fa-weibo"></i>
  </a>
</aside>
      <hr>
<aside id="comments" class="disqus">
  <div id="container"></div>
  <!-- <link rel="stylesheet" href="/assets/css/gitment.css">
  <script src="https://imsun.github.io/gitment/dist/gitment.browser.js"></script>
  <script>
  var gitment = new Gitment({
    id: "https://www.desgard.com/DGDownloaderButton-2/", 
    owner: 'Desgard',
    repo: 'desgard.github.com',
    oauth: {
      client_id: 'e2612df42f3f2a83e71c',
      client_secret: 'b53e85b314bb24a6d06773e48bbb62a4de3b8b3a',
    },
  })
  gitment.render('container')
  </script> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<div id='gitalk-container'></div>
<script>
    const gitalk = new Gitalk({
        id: "https://www.desgard.com/DGDownloaderButton-2/", 
        clientID: 'e2612df42f3f2a83e71c',
        clientSecret: 'b53e85b314bb24a6d06773e48bbb62a4de3b8b3a',
        repo: 'desgard.github.com',
        owner: 'Desgard',
        admin: ['Desgard'],
        // facebook-like distraction free mode
        distractionFreeMode: false
    })
    gitalk.render('gitalk-container')
</script>
</aside>
  </footer>
</article>
    </main>
<footer class="footer">
  <div class="container">
    <ul class="icons">
      <li>
        <a href="https://github.com/desgard" class="icon-github" target="_blank">
          <i class="fa fa-github"></i>
        </a>
      </li>
      <li>
        <a href="https://www.facebook.com/desgard.duan" class="icon-facebook" target="_blank">
          <i class="fa fa-facebook"></i>
        </a>
      </li>
      <li>
        <a href="https://twitter.com/Desgard_Duan" class="icon-twitter" target="_blank">
          <i class="fa fa-twitter"></i>
        </a>
      </li>
      <li>
        <a href="https://stackoverflow.com/users/6119149/desgard-duan" class="icon-github" target="_blank">
          <i class="fa fa-stack-overflow"></i>
        </a>
      </li>
      <li>
        <a href="https://weibo.com/desgard" class="icon-instagram" target="_blank">
          <i class="fa fa-weibo"></i>
        </a>
      </li>
    </ul>
    <p>
      <q>I write many code to write less code.💻</q>
      <small>– Gua</small>
    </p>
    <small class="clearfix">
      Powered by <a href="http://jekyllrb.com" target="_blank">Jekyll</a> • <a href="https://github.com/desgard" target="_blank">Open source <i class="fa fa-heart"></i></a>
    </small>
  </div>
</footer>
<a class="scroll-up fa fa-chevron-up bounce" href="#" data-position="0"></a>
<div id="modalSearch" class="modal">
  <div class="modal__overlay"></div>
  <div class="modal__content">
    <a href="#!" class="modal-close" data-modal-close>&times;</a>
    <div class="search-container">
      <input type="text" id="search-input" placeholder="Search articles">
      <ul id="results-container"></ul>
    </div>
  </div>
</div>
    <script src="/assets/main-52d417e8a6ff9f5b168386d37c96338a.js"></script>
  </body>
  <script>
    var link = "" ;
    var os = function() {  
      var ua = navigator.userAgent,  
      isWindowsPhone = /(?:Windows Phone)/.test(ua),  
      isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,   
      isAndroid = /(?:Android)/.test(ua),   
      isFireFox = /(?:Firefox)/.test(ua),   
      isChrome = /(?:Chrome|CriOS)/.test(ua),  
      isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),  
      isPhone = /(?:iPhone)/.test(ua) && !isTablet,  
      isPc = !isPhone && !isAndroid && !isSymbian;  
      return {  
        isTablet: isTablet,  
        isPhone: isPhone,  
        isAndroid : isAndroid,  
        isPc : isPc  
      };  
    }();  
    if (link.length > 0) {
      if (os.isAndroid || os.isPhone) {
        location.replace(link);
      }
    }
  </script>
</html>